home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Frameworks / MADE 1.0.1 / Essential Shell.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-04  |  2.3 KB  |  116 lines  |  [TEXT/CWIE]

  1. // MADE - Macintosh Application Development Essentials
  2. // ---------------------------------------------------
  3.  
  4. // (c) Gideon Greenspan, Sig Software - June 1997 - http://www.kagi.com/gdg/
  5.  
  6. // These files can only be used for experimental standalone purposes. To obtain
  7. // fully commented code, and licenses for standalone, shareware, internal and
  8. // commercial usage, run the enclosed Register application.
  9.  
  10. // Essential Shell.h
  11. //
  12. // The application entry point, initialisations and Gestalt checking.
  13. //
  14. // Version 1.0.0 - 10th November 1996
  15. // Version 1.0.1 - 4th June 1997
  16. //                 Fixed macro, function names
  17.  
  18. #include "Essential Headers.h"
  19. #include "Essential Prototypes.h"
  20.  
  21. Boolean        applicationHasQuit=false;
  22. void*        dummy;
  23.  
  24. void main()
  25. {
  26.     Error    error=0;
  27.     InitGraf(&qd.thePort);
  28.     InitFonts();
  29.     InitWindows();
  30.     InitMenus();
  31.     TEInit();
  32.     InitDialogs(0L);
  33.     InitCursor();
  34.     MoreMasters();
  35.     MaxApplZone();
  36.  
  37. #if Use_AppleEvents
  38.     
  39.     if (CheckGestaltBit(gestaltAppleEventsAttr, gestaltAppleEventsPresent)) {
  40.         error=InitAppleEvents();
  41.         TestError(error);
  42.  
  43.         #if Insist_On_AppleEvent_Support
  44.             if (error) goto quitApplication;
  45.         #endif
  46.  
  47.     } else {
  48.         #if Insist_On_AppleEvent_Support
  49.             TestError(System_Software_Version_Error);
  50.             goto quitApplication;
  51.         #endif
  52.     } 
  53.  
  54. #endif
  55.             
  56. #if Use_Drag_Manager
  57.  
  58.     if (CheckGestaltBit(gestaltDragMgrAttr, gestaltDragMgrPresent)) {
  59.         error=InitDragManager();
  60.         TestError(error);
  61.  
  62.         #if Insist_On_Drag_Manager_Support
  63.             if (error) goto quitApplication;
  64.         #endif
  65.  
  66.     } else {
  67.  
  68.         #if Insist_On_Drag_Manager_Support
  69.             TestError(System_Software_Version_Error);
  70.             goto quitApplication;
  71.         #endif
  72.     } 
  73.     
  74. #endif
  75.  
  76. #if Project_Under_Development && Initialise_Allocated_Memory
  77.  
  78.     dummy=(void*)NewPtr(MaxMem((Size*)&dummy));
  79.     if (dummy) {
  80.  
  81.         InitialiseMemory(dummy, GetPtrSize((Ptr)dummy));
  82.         DisposPtr((Ptr)dummy);
  83.     }
  84.  
  85. #endif
  86.  
  87.     error=InitMenuBar();
  88.     TestError(error);
  89.     if (error) goto quitApplication;
  90.     
  91.     MyInitialiseApplication();
  92.  
  93.     ExecutionBody();
  94.     
  95.     quitApplication:;
  96. }
  97.  
  98. void ExecutionBody()
  99. {
  100.     while (!applicationHasQuit)
  101.         MainEventLoop();
  102.     
  103.     MyClearUpApplication();
  104.     
  105.     ExitToShell();
  106. }
  107.  
  108. Boolean CheckGestaltBit(OSType selector, char bit)
  109. {
  110.     long         response;
  111.     
  112.     if (Gestalt(selector, &response)) return false;
  113.     else if (!(response&(1<<bit))) return false;
  114.     else return true;
  115. }
  116.